package com.mine.modules.quartz.job;

import com.mine.modules.vm.service.IVmMonitorRegionsService;
import com.mine.modules.vm.service.IVmMonitorService;
import com.mine.modules.vm.service.IVmSensorService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Configuration
public class ScheduleTask {

    @Resource
    private IVmSensorService vmSensorService;

    @Resource
    private IVmMonitorService vmMonitorService;

    @Resource
    private IVmMonitorRegionsService vmMonitorRegionsService;

//    @PostConstruct
//    public void initTask() {
//        vmSensorService.synSensors();
//        vmMonitorRegionsService.synRegions();
//        vmMonitorService.synCameras();
//    }

    /**
     * 同步传感器数据
     */
    @Scheduled(cron = "0 0 2 * * ?")
    private void sensorTask() {
        vmSensorService.synSensors();
    }

    /**
     * 同步监控视频分类数据
     */
    @Scheduled(cron = "0 0 3 * * ?")
    private void monitorTreeTask() {
        vmMonitorRegionsService.synRegions();
    }

    /**
     * 同步监控视频数据
     */
    @Scheduled(cron = "0 0 4 * * ?")
    private void monitorTask() {
        vmMonitorService.synCameras();
    }

}
